package com.d3works.apps.businessproduction.service;

import com.d3works.apps.hr.db.TimesheetLine;
import com.d3works.apps.hr.db.repo.TimesheetRepository;
import com.d3works.apps.production.db.OperationOrder;
import java.util.Objects;

public class OperationOrderValidateBusinessServiceImpl
    implements OperationOrderValidateBusinessService {

  @Override
  public long checkTimesheet(OperationOrder operationOrder) {
    return operationOrder.getTimesheetLineList().stream()
        .map(TimesheetLine::getTimesheet)
        .filter(Objects::nonNull)
        .filter(timesheet -> timesheet.getStatusSelect() == TimesheetRepository.STATUS_CONFIRMED)
        .count();
  }
}
